package wp.wf.com.myapplication.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

import wp.wf.com.myapplication.R;
import wp.wf.com.myapplication.adapter.RecycleBaseAdapter;
import wp.wf.com.myapplication.bean.MyViewHolder;

/**
 * Created by KF on 2016/4/25.
 */
@ContentView(R.layout.fragment_main)
public class OneFragment extends BaseFragment {
    @ViewInject(R.id.rv)
    private RecyclerView rv;
    private List<String> dataList;

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        dataList = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            dataList.add("测试" + i);
        }
        RecycleBaseAdapter<String> adapter = new RecycleBaseAdapter<String>(getContext(), dataList, R.layout.rv_item) {
            @Override
            public void onBindView(MyViewHolder holder, int position, String s) {
                holder.setText(R.id.tv_test, s);
            }
        };
        rv.setLayoutManager(new LinearLayoutManager(getContext()));
        rv.setAdapter(adapter);
    }
}
